package com.gec.yhzh.controller;


import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.gec.yhzh.entity.Appointment;
import com.gec.yhzh.entity.AppointmentVaccine;
import com.gec.yhzh.service.IAppointmentService;
import com.gec.yhzh.service.IAppointmentVaccineService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * <p>
 * 预约 前端控制器
 * </p>
 *
 * @author jerry
 * @since 2025-03-10
 */
@RestController
@RequestMapping("/appointment")
public class AppointmentController {
    @Autowired
    private IAppointmentService iappointmentService;

    //JSON解析工具
    ObjectMapper objectMapper = new ObjectMapper();
    @GetMapping("/query")
    public String  queryDoctors() throws JsonProcessingException {
        Map<String, Object> result = new HashMap<>();
        List<Appointment> AppointmentList = iappointmentService.list();
        if (AppointmentList == null || AppointmentList.isEmpty()) {
            result.put("flag",false );
            return objectMapper.writeValueAsString(result);
        }
        result.put("flag",true );
        result.put("list",AppointmentList );
        return objectMapper.writeValueAsString(result);
    }
}
